package com.spring.springboot.Service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.spring.springboot.entity.UsersEntity;
import com.spring.springboot.jpa.UsersJPA;

/**
*@author LSY
*Time: 2018年12月13日下午4:59:01
*
*
*/
@Service
public class UsersService implements UserDetailsService{

	@Autowired
	UsersJPA usersJPA;

	@Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        UsersEntity user = usersJPA.findByUsername(username);
        if(user == null)
        {
            throw new UsernameNotFoundException("未查询到用户："+username+"信息！");
        }
        return user;
    }
	
	
	
}
